<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>

<!--  2010-07-03 教师分组（按照各教研室看教师分组） -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<title>教师分组</title>
	<link href="<%=path%>/css/index_css.css" rel="stylesheet" type="text/css" />
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
	<script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
	<script language="javascript" src="<%=path %>/js/syAjax.js"></script>
	<script type="text/javascript">
	window.onload = function(){
      	
      	resizeIframe();
        new Anim.DD($("items"), $("title"));
		$("items").style.left = "50px";
		$("items").style.top = "100px";
          
        
        load();
      };
      //全局变量
      var tdID=null;	//选中TD对象
      var isEditor=1;	//是否为编辑状态 0：可编辑 1：不可编辑
	var objectHIDDENID;
	var orgId;
	function giveParamArr(){
		return document.getElementById(objectHIDDENID).value;
	}

	
      //显示遮罩
      function displayModuleDiv(){
		document.getElementById("items").style.display = "";	
		resizeIframe();
	}
	
	
	//关闭div
	function closeDIV(){
		document.getElementById("items").style.display = "none";
		
	}
	function doChooseUser(returnStr){
		if(returnStr==undefined){
			return;
		}
		if(returnStr!=null && returnStr!=""){
		var idStr="";
			var UserArr = returnStr.substring(0,returnStr.length-1).split(",");
			var UserNameStr="";
			for(var i=0;i<UserArr.length;i++){
				var user=UserArr[i];
				var sonArr=user.split("_");
				if((i+1)%5==0){
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"<input name=\"ppp_"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/><br>";
				}else{
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+"<input name=\"ppp_"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/>";	
				}
				idStr+=sonArr[0]+",";
			}
			document.getElementById(objectHIDDENID).value=idStr;
			if(UserNameStr!=""){										
				document.getElementById('ppp_'+orgId).innerHTML=UserNameStr;					
			}
		}else{
			document.getElementById('ppp_'+orgId).innerHTML="";
		}
		closeDIV();
	}
	function showModel2(thisOrgId){
		orgId=thisOrgId;
		objectHIDDENID="p"+thisOrgId;
		//判断是否为当前年度
		if(document.getElementById('year').value=='${applicationScope.currentYear}'){
		//判断是否为可编辑状态
	      	if(isEditor==0){
				document.getElementById("selectUserIframe").src="<%=path%>/toSelectTeacherorganizationAction.action?years=${applicationScope.currentYear}&role.roleId=member&actionURL=saveUserOrgRoleRelationorganizationAction.action&t="+new Date();
				displayModuleDiv();
			}else{
	      	    alert("请设为编辑状态!");
	      	  }
      	  }else{
      		alert("不是当前年度，不能进行此操作！");
      	}
	}
      
		function getAllYearCallBack(yearMap) {
        DWRUtil.addOptions("year", yearMap);
        if('${year}'!="")
    	{
    	  document.getElementById('year').value="${year}";
    	}else if('${currentYear}'!="")
    	{
    	  document.getElementById('year').value="${currentYear}";
    	}
    } 
    
    //改变编辑状态
   	  function changeEditor(a)
   	  {
   	    if(isEditor==0)
   	    {
   	    	a.innerHTML="<font color='#000000'>设为编辑状态</font>";
   	    	isEditor=1;
   	    }else{
   	    	a.innerHTML="<font color='red'>设为非编辑状态</font>";
   	    	isEditor=0;
   	    }
   	  }
    function tdClick(address)
    {
      window.location.href=address;
    }
    function load()
    {
    	shiyueDwr.getAllYear(getAllYearCallBack);
    }
	</script>

  </head>
  <body>
  <div id="contentDIV" style="position:absolute;width:100%; padding:5px; background-color:#ffffff;z-index:1;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">教师分组</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="<%=path%>/images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_18.gif" class="f_6" onclick="tdClick('findTeaAndDeporganizationAction.action?years=${currentYear}&orgType=2&forwardPage=teaToDepartment');" style="cursor:pointer;">部门分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="<%=path%>/images/sywesp_18.gif" class="f_6" onclick="tdClick('<%=path %>/findUserGradeGradeAndClassAction.action?year=${applicationScope.currentYear }&forwardPage=teaToGrade');" style="cursor:pointer;">年级分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"><br></td>
              </tr>
            </table></td>
            <td width="5" align="left">&nbsp;</td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"><br></td>
                <td align="center" background="<%=path%>/images/sywesp_25.gif" class="f_9">教研室分组</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"><br></td>
              </tr>
            </table></td>
            <td align="left">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>

                <td width="38%" align="left"><a href="<%=path %>/findTeaAndDeporganizationAction.action?orgType=1&years=${currentYear }&forwardPage=teaToStaffRoom">按照各教师看分组</a> ┆ 按照各教研室看分组 <br /></td>

                <td width="46%" align="right" valign="top">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="tdClick('findTeaAndDeporganizationAction.action?orgType=1&years='+this.value+'&forwardPage=staffRoomToTea');">
                  </select>
                  </label></td>
               <td width="16%" style="border:solid #CCCCCC 1px;" align="right" class="f_4" onclick="changeEditor(this);" style="cursor:pointer;"><font color="#000000">设为编辑状态</font></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top">
             <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
              <tr>
                <td width="9%" height="30" align="center" bgcolor="#DBE9F6" class="f_4" nowrap="nowrap">教研室名称</td>
                <td width="91%" align="left" bgcolor="#DBE9F6" class="f_4">姓名</td>
                </tr>
              <c:forEach items="${requestScope.AllOrganizationByType}" var="org"><c:set value="" var="totalArr"></c:set>
                <tr>
                <td height="30" align="center" bgcolor="#FFFFFF" class="f_4" nowrap="nowrap">${org.name }&nbsp;</td>
                <td align="left" valign="middle" bgcolor="#FFFFFF" id="ppp_${org.organizationId }" onclick="showModel2('${org.organizationId }');" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''" style="cursor:pointer;">&nbsp;
                 <!-- <table width="95%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <c:set value="1" var="i" />
                    <c:forEach items="${requestScope.UserList}" var="user">
                      <c:if test="${! empty requestScope.mapList}">
	                		<c:set value='${user.userId}${org.organizationId}' var="UserOrg" />
		                		<c:if test="${! empty requestScope.mapList[UserOrg]}">
		                			<td height="25" align="left" width="25%">${user.name }</td>
		                		</c:if>
                		 </c:if>
                      <c:if test="${i%4==0}">
                        </tr><tr>
                      </c:if>
                      <c:set value="${i+1}" var="i" />
                    </c:forEach>
                  </tr>
                 </table> -->
                 <%int i=0; %>
                    <c:forEach items="${requestScope.UserList}" var="user">
                      <c:if test="${! empty requestScope.mapList}">
	                		<c:set value='${user.userId}${org.organizationId}' var="UserOrg" />
		                		<c:if test="${! empty requestScope.mapList[UserOrg]}">
		                		<c:set value="${user.userId},${totalArr}" var="totalArr"></c:set>
		                	 <%
		                		i++;
		                		if(i%5==0){
		                	 %>
		                	 	&nbsp;&nbsp;${user.name }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="ppp_${org.organizationId}" type="hidden" value="${user.userId}"/><br>
		                	 <%}else{ %>
		                	 	&nbsp;&nbsp;${user.name }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="ppp_${org.organizationId}" type="hidden" value="${user.userId}"/>
		                	 <%} %>
		                			
		                		</c:if>
                		 </c:if>
                    </c:forEach>
                    <input type="hidden" id="p${org.organizationId }" value="${totalArr}"/>
                 </td>
                </tr>
              </c:forEach>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<div id="items" style="position: absolute; width: 730px;height:600px; top:100px; left:200px; padding-bottom:8px; background-color:#ECF7FD;z-index:10; border:3px solid #3A6EA5; display: none;" >
	<div style="width:100%;top:100px;left:200px;" id="title">
		<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" bgcolor="#3A6EA5">
						<tr style=" height: 30px;">
		<td>&nbsp;&nbsp;<font color='#FFFFFF'>请选择教师</font></td>
		<td align="right"><a href="javascript:closeDIV();" style="text-decoration: none;"><span style="color: #000000; font-size:;">[关闭]</span></a></td>
						</tr>
		</table>
	</div>
	<div style="width:100%;top:100px;left:200px;height: 100%">
	<iframe name="selectUserIframe" id="selectUserIframe" src="" style="width:100%;height: 100%" align="middle"  frameborder="0"></iframe>   
	</div>
		
</div>
  </body>
</html>
